Problem Note 47182: Adding a leading zero to the %s directive in a PICTURE statement in PROC FORMAT does not insert a leading zero as documented
New in SAS® 9.3 is the ability to format fractional seconds with the %s directive in the PICTURE statement in PROC FORMAT.
Attempting to add a leading zero to the formatted value of fractional seconds by inserting a leading zero before the picture directive (for example, %0s) does not insert a leading zero. The documentation for the PICTURE statement in the FORMAT procedure incorrectly states that you can insert a leading zero before this directive.
Please click the Full Code tab to see an example of this issue as well as a workaround.
Operating System and Release Information
SAS System | Base SAS | 64-bit Enabled Solaris | 9.3 TS1M0 | 9.4 TS1M2 |
HP-UX IPF | 9.3 TS1M0 | 9.4 TS1M2 |
Linux | 9.3 TS1M0 | 9.4 TS1M2 |
Linux for x64 | 9.3 TS1M0 | 9.4 TS1M2 |
Solaris for x64 | 9.3 TS1M0 | 9.4 TS1M2 |
64-bit Enabled HP-UX | 9.3 TS1M0 | 9.4 TS1M2 |
64-bit Enabled AIX | 9.3 TS1M0 | 9.4 TS1M2 |
Windows Vista for x64 | 9.3 TS1M0 | |
Windows 7 Ultimate x64 | 9.3 TS1M0 | 9.4 TS1M2 |
Windows 7 Ultimate 32 bit | 9.3 TS1M0 | 9.4 TS1M2 |
Windows 7 Professional x64 | 9.3 TS1M0 | 9.4 TS1M2 |
Windows 7 Home Premium x64 | 9.3 TS1M0 | 9.4 TS1M2 |
Windows 7 Home Premium 32 bit | 9.3 TS1M0 | 9.4 TS1M2 |
Windows 7 Enterprise 32 bit | 9.3 TS1M0 | 9.4 TS1M2 |
Microsoft Windows XP Professional | 9.3 TS1M0 | |
Microsoft Windows Server 2008 R2 | 9.3 TS1M0 | 9.4 TS1M2 |
Microsoft Windows Server 2008 | 9.3 TS1M0 | 9.4 TS1M2 |
Microsoft Windows Server 2003 for x64 | 9.3 TS1M0 | |
Microsoft Windows Server 2003 Standard Edition | 9.3 TS1M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.3 TS1M0 | |
Microsoft® Windows® for x64 | 9.3 TS1M0 | 9.4 TS1M2 |
z/OS | 9.3 TS1M0 | 9.4 TS1M2 |
Z64 | 9.3 TS1M0 | 9.4 TS1M2 |
Microsoft Windows Server 2003 Enterprise Edition | 9.3 TS1M0 | |
Microsoft Windows Server 2008 for x64 | 9.3 TS1M0 | 9.4 TS1M2 |
Windows 7 Enterprise x64 | 9.3 TS1M0 | 9.4 TS1M2 |
Windows 7 Professional 32 bit | 9.3 TS1M0 | 9.4 TS1M2 |
Windows Vista | 9.3 TS1M0 | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
Attempting to add a leading zero to the formatted value of fractional seconds by inserting a leading zero before the picture directive (for example, %0s) does not insert a leading zero. The documentation for the FORMAT procedure incorrectly states that you can insert a leading zero before this directive.
The PICTURE statement below produces the formatted value as 2012-05-01-13.05. 2.87654. To add a leading zero to the fractional seconds portion, you can use the TRANSLATE function. The new formatted value is 2012-05-01-13.05.02.87654, as desired.
proc format;
picture DB2TMS
low-high = '%Y-%0m-%0d-%0H.%0M.%0s' (datatype=datetime);
run;
data test;
olddb2tms1=dhms('01may12'd,13,5,2.87654);
newdb2tms1= translate(put(olddb2tms1,DB2TMS26.6),'0',' ');
run;
title "Problem Note #47182";
proc print data=test;
format olddb2tms1 DB2TMS26.6;
run;
Attempting to add a leading zero to the formatted value of fractional seconds by inserting a zero before the picture directive (for example, %0s) does not insert a leading zero as documented.
Type: | Problem Note |
Priority: | medium |
Date Modified: | 2012-08-09 16:36:26 |
Date Created: | 2012-08-08 16:49:28 |